home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Games Collection 1 / software vault.zip / software vault / CDR10 / XLIB06.ZIP / DEMO1.C < prev    next >
C/C++ Source or Header  |  1993-10-07  |  23KB  |  572 lines

  1. /* VERY QUICK AND ULTRA-DIRTY DEMO USING XLIB */
  2.  
  3. /* Simple Demo of MODE X Split screen and panning  */
  4. /* Compile using Turbo C and Tasm                  */
  5.  
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <conio.h>
  9. #include <ctype.h>
  10. #include <alloc.h>
  11. #include <dos.h>
  12. #include "Xlib_all.h"
  13.  
  14. #define MAX_OBJECTS  10
  15.  
  16. static char *texttest[6] =
  17.  {"This is a demonstration of the fonts ",
  18.   "available in XLIB. Notice fixed and  ",
  19.   "variabe spaced fonts are supported but",
  20.   "are limited to a maximum of 8 pixels in",
  21.   "width. Height of the characters is    ",
  22.   "ofcourse unlimited..."};
  23.  
  24. typedef struct {
  25.    int X,Y,Width,Height,XDir,YDir,XOtherPage,YOtherPage;
  26.    char far * Image;
  27.    char far * bg;
  28.    char far * bgOtherPage;
  29. } AnimatedObject;
  30.  
  31. AnimatedObject objects[MAX_OBJECTS];
  32. int object_count=0;
  33.  
  34. static char  bm[] = {4,12,
  35.   /* plane 0 */
  36.   2,2,2,2,2,1,1,1,2,1,1,1,2,3,3,1,
  37.   2,0,0,3,2,0,0,3,2,0,0,3,2,0,0,3,
  38.   2,3,3,1,2,1,1,1,2,1,1,1,2,2,2,2,
  39.   /* plane 1 */
  40.   2,2,2,2,1,1,1,1,1,1,1,1,1,3,3,1,
  41.   1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,
  42.   1,3,3,1,1,1,1,1,1,1,1,1,2,2,2,2,
  43.   /* plane 2 */
  44.   2,2,2,2,1,1,1,1,1,1,1,1,1,3,3,1,
  45.   1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,
  46.   1,3,3,1,1,1,1,1,1,1,1,1,2,2,2,2,
  47.   /* plane 3 */
  48.   2,2,2,2,1,1,1,2,1,1,1,2,1,3,3,2,
  49.   3,0,0,2,3,0,0,2,3,0,0,2,3,0,0,2,
  50.   1,3,3,2,1,1,1,2,1,1,1,2,2,2,2,2};
  51.  
  52. static char  bm2[] = {4,12,
  53.    /* plane 0 */
  54.    2,2,2,2,2,4,4,4,2,4,4,4,2,2,2,4,
  55.    2,0,0,2,2,0,0,2,2,0,0,2,2,0,0,2,
  56.    2,2,2,4,2,4,4,4,2,4,4,4,2,2,2,2,
  57.    /* plane 1 */
  58.    2,2,2,2,4,4,4,4,4,4,4,4,4,2,2,4,
  59.    4,0,0,4,4,0,0,4,4,0,0,4,4,0,0,4,
  60.    4,2,2,4,4,4,4,4,4,4,4,4,2,2,2,2,
  61.    /* plane 2 */
  62.    2,2,2,2,4,4,4,4,4,4,4,4,4,2,2,4,
  63.    4,0,0,4,4,0,0,4,4,0,0,4,4,0,0,4,
  64.    4,2,2,4,4,4,4,4,4,4,4,4,2,2,2,2,
  65.    /* plane 2 */
  66.    2,2,2,2,4,4,4,2,4,4,4,2,4,2,2,2,
  67.    2,0,0,2,2,0,0,2,2,0,0,2,2,0,0,2,
  68.    4,2,2,2,4,4,4,2,4,4,4,2,2,2,2,2};
  69.  
  70. int textwindow_x=0,textwindow_y=0;
  71. char far * pal,far * pal2;
  72. char palscrolldir=1;
  73. char far * userfnt1;
  74.  
  75.  
  76.  
  77. void drawtext(int height){
  78.   int i;
  79.   for (i=0;i<6;i++)
  80.     x_printf(textwindow_x+5,50+i*(height+2),VisiblePageOffs,9,texttest[i]);
  81. }
  82.  
  83. /* initialize a new object */
  84. void init_object(int x,int y,int width, int height, int xdir, int ydir,
  85.   char far * image){
  86.   int i;
  87.   objects[object_count].X = objects[object_count].XOtherPage = x;
  88.   objects[object_count].Y = objects[object_count].YOtherPage = y;
  89.   objects[object_count].Width = width;
  90.   objects[object_count].Height = height;
  91.   objects[object_count].XDir = xdir;
  92.   objects[object_count].YDir = ydir;
  93.   objects[object_count].Image = image;
  94.   objects[object_count].bg = (char far *) farmalloc(4*width*height+20);
  95.   objects[object_count].bgOtherPage = (char far *) farmalloc(4*width*height+20);
  96.   x_get_pbm(x,y,(unsigned)width,height,VisiblePageOffs,
  97.     objects[object_count].bg);
  98.   x_get_pbm(x,y,(unsigned)width,height,HiddenPageOffs,
  99.     objects[object_count].bgOtherPage);
  100.   object_count++;
  101. }
  102.  
  103. /* Move the specified object, bouncing at the edges of the screen and
  104.    remembering where the object was before the move for erasing next time */
  105. void MoveObject(AnimatedObject * ObjectToMove) {
  106.    int X, Y;
  107.    char far *cptr;
  108.    X = ObjectToMove->X + ObjectToMove->XDir;
  109.    Y = ObjectToMove->Y + ObjectToMove->YDir;
  110.    if ((X < 0) || (X > (ScrnLogicalPixelWidth-((ObjectToMove->Width)<<2)))) {
  111.       ObjectToMove->XDir = -ObjectToMove->XDir;
  112.       X = ObjectToMove->X + ObjectToMove->XDir;
  113.    }
  114.    if ((Y < 0) || (Y > (ScrnLogicalHeight-ObjectToMove->Height))) {
  115.       ObjectToMove->YDir = -ObjectToMove->YDir;
  116.       Y = ObjectToMove->Y + ObjectToMove->YDir;
  117.    }
  118.    /* Remember previous location for erasing purposes */
  119.    ObjectToMove->XOtherPage = ObjectToMove->X;
  120.    ObjectToMove->YOtherPage = ObjectToMove->Y;
  121.    ObjectToMove->X = X; /* set new location */
  122.    ObjectToMove->Y = Y;
  123.    cptr = ObjectToMove->bg;
  124.    ObjectToMove->bg = ObjectToMove->bgOtherPage;
  125.    ObjectToMove->bgOtherPage = cptr;
  126. }
  127.  
  128. void animate(void){
  129.  int i;
  130.  for(i=object_count-1;i>=0;i--){
  131.   x_put_pbm(objects[i].XOtherPage,objects[i].YOtherPage,
  132.      HiddenPageOffs,objects[i].bgOtherPage);
  133.  }
  134.  for(i=0;i<object_count;i++){
  135.   MoveObject(&objects[i]);
  136.  
  137.   x_get_pbm(objects[i].X,objects[i].Y,
  138.     (unsigned)objects[i].Width,objects[i].Height,HiddenPageOffs,
  139.     objects[i].bg);
  140.   x_put_masked_pbm(objects[i].X,objects[i].Y,HiddenPageOffs,
  141.     objects[i].Image);
  142.  }
  143. }
  144.  
  145. void clear_objects(void){
  146.  int i;
  147.  for(i=object_count-1;i>=0;i--){
  148.   x_put_pbm(objects[i].XOtherPage,objects[i].YOtherPage,
  149.      HiddenPageOffs,objects[i].bgOtherPage);
  150.  }
  151. }
  152.  
  153.  
  154. void textwindow(int Margin){
  155.    int x0=0+Margin;
  156.    int y0=0+Margin;
  157.    int x1=ScrnPhysicalPixelWidth-Margin;
  158.    int y1=ScrnPhysicalHeight-Margin;
  159.    x_rect_fill(x0, y0, x1,y1,VisiblePageOffs,1);
  160.    x_line(x0,y0,x1,y0,2,VisiblePageOffs);
  161.    x_line(x0,y1,x1,y1,2,VisiblePageOffs);
  162.    x_line(x0,y0,x0,y1,2,VisiblePageOffs);
  163.    x_line(x1,y0,x1,y1,2,VisiblePageOffs);
  164.    x_line(x0+2,y0+2,x1-2,y0+2,2,VisiblePageOffs);
  165.    x_line(x0+2,y1-2,x1-2,y1-2,2,VisiblePageOffs);
  166.    x_line(x0+2,y0+2,x0+2,y1-2,2,VisiblePageOffs);
  167.    x_line(x1-2,y0+2,x1-2,y1-2,2,VisiblePageOffs);
  168.    textwindow_x=x0;
  169.    textwindow_y=y0;
  170.  
  171. }
  172.  
  173.  
  174. void wait_for_keypress(void){
  175.   x_show_mouse();
  176.   while(kbhit()) getch();
  177.   palscrolldir^=1;
  178.  
  179.   do {
  180.     x_rot_pal_struc(pal,palscrolldir);
  181.     MouseFrozen=1;
  182.     x_put_pal_struc(pal);
  183.     x_update_mouse();
  184.   } while (!kbhit() && !(MouseButtonStatus==LEFT_PRESSED));
  185.   while(MouseButtonStatus==LEFT_PRESSED);
  186.   while(kbhit()) getch();
  187.  
  188. }
  189.  
  190.  
  191. void exitfunc(void){
  192.   x_mouse_remove();
  193.   x_remove_vsync_handler();
  194.   x_text_mode();
  195.   printf("Thanks to everyone who assisted in the development of XLIB.\n");
  196.   printf("\nSpecial thanks to Matthew Mackenzie for contributing \n");
  197.   printf("lots of code, documentation and ideas.\n\n");
  198.   printf("If you make any money using this code and you're the generous\n");
  199.   printf("type please send us some, or at least a copy of your program!\n");
  200. }
  201.  
  202. int terminate(void){
  203.   exit(0);
  204. }
  205.  
  206. void intro_1(void){
  207.   x_set_rgb(1,40,40,40); /* BG Gray */
  208.   x_set_rgb(2,63,63,0);  /* Bright Yellow  */
  209.   x_set_rgb(3,63,0,0);   /* Bright Red     */
  210.   x_set_rgb(4,0,63,0);   /* Bright Green   */
  211.   x_set_rgb(5,0,0,63);   /* Bright Blue    */
  212.   x_set_rgb(6,0,0,28);   /* Dark Blue      */
  213.   x_set_rgb(7,0,28,0);   /* Dark Green     */
  214.   x_set_rgb(8,28,0,0);   /* Dark red       */
  215.   x_set_rgb(9,0,0,38);   /* Med Blue       */
  216.  
  217.   textwindow(20);
  218.   x_set_font(1);
  219.   x_printf(textwindow_x+54,textwindow_y+4,VisiblePageOffs,6,"     XLIB Version 6.0");
  220.   x_printf(textwindow_x+53,textwindow_y+3,VisiblePageOffs,2,"     XLIB Version 6.0");
  221.   x_set_font(0);
  222.   x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6,"       Not the Unix version");
  223.   x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,2,"       Not the Unix version");
  224.  
  225.   x_printf(textwindow_x+24,168,VisiblePageOffs,6,"     Press any key to continue");
  226.   x_printf(textwindow_x+23,167,VisiblePageOffs,2,"     Press any key to continue");
  227. }
  228.  
  229. void subsequent_page(void){
  230.   x_hide_mouse();
  231.   textwindow(20);
  232.   x_set_font(1);
  233.   x_printf(textwindow_x+54,textwindow_y+4,VisiblePageOffs,6,"     XLIB Version 6.0");
  234.   x_printf(textwindow_x+53,textwindow_y+3,VisiblePageOffs,2,"     XLIB Version 6.0");
  235.   x_set_font(0);
  236.   x_printf(textwindow_x+24,168,VisiblePageOffs,6,"     Press any key to continue");
  237.   x_printf(textwindow_x+23,167,VisiblePageOffs,2,"     Press any key to continue");
  238. }
  239.  
  240. void load_user_fonts(void){
  241.   FILE *f;
  242.   f=fopen("var6x8.fnt","rb");
  243.   /* read char by char as fread wont read to far pointers in small model */
  244.   { int i; char c;
  245.     for (i=0;i<256*8+4;i++){
  246.       fread(&c,1,1,f);
  247.       *(userfnt1+i)=c;
  248.     }
  249.   }
  250.  
  251.   fclose(f);
  252.  
  253.   x_register_userfont(userfnt1);
  254.  
  255. }
  256.  
  257.  
  258.  
  259. void main(){
  260.   int  i, j, xinc, yinc, Margin;
  261.   char ch;
  262.   WORD curr_x=0, curr_y=0;
  263.  
  264.   pal    = (char far *) farmalloc(256*3);
  265.   pal2   = (char far *) farmalloc(256*3);
  266.   userfnt1 = (char far *) farmalloc(256*16+4);
  267.  
  268.  
  269.   /* INITIALIZE XLIB */
  270.  
  271.   /* we set up Mode X 360x200x256 with a logical width of ~ 500 */
  272.   /* pixels; we actually get 496 due to the fact that the width */
  273.   /* must be divisible by 8                                     */
  274.  
  275.   x_text_mode(); /* make sure VGA is in color mode, if possible */
  276.   x_set_mode(X_MODE_360x200,500);           /* actually is set to 496      */
  277.   x_install_vsync_handler(2);
  278.   x_set_splitscreen(ScrnPhysicalHeight-60); /* split screen 60 pixels high */
  279.   x_set_doublebuffer(220);
  280.   x_text_init();
  281.   x_hide_splitscreen();
  282.   x_mouse_init();
  283.   MouseColor=2;
  284.   atexit(exitfunc);
  285.  
  286.   /* DRAW BACKGROUND LINES */
  287.  
  288.   for(j=0;j<ScrnPhysicalHeight;j++){
  289.    x_line(0,j,ScrnLogicalPixelWidth,j,16+(j%239),VisiblePageOffs);
  290.   }
  291.  
  292.   ctrlbrk(terminate);
  293.   x_get_pal_struc(pal, 240,16);
  294.   load_user_fonts();
  295.  
  296.   intro_1();
  297.   x_set_font(2);
  298.   x_hide_mouse();
  299.   x_printf(textwindow_x+5,50   ,VisiblePageOffs,9, "   Hi, folks. This is yet another FREEWARE Mode X");
  300.   x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " graphics library. It is by no means complete,");
  301.   x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " but I believe it contains a rich enough set of");
  302.   x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " functions to achieve its design goal - to be");
  303.   x_printf(textwindow_x+5,50+32,VisiblePageOffs,9, " a game development oriented library for");
  304.   x_printf(textwindow_x+5,50+40,VisiblePageOffs,9, " Borland TC/BC/BC++ and TASM programmers.");
  305.  
  306.   x_printf(textwindow_x+5,50+48,VisiblePageOffs,9, "   This library comes with TASM and C sources.");
  307.   x_printf(textwindow_x+5,50+56,VisiblePageOffs,9, " It was inspired by the DDJ Graphics column and");
  308.   x_printf(textwindow_x+5,50+64,VisiblePageOffs,9, " many INTERNET and USENET authors who, unlike the");
  309.   x_printf(textwindow_x+5,50+72,VisiblePageOffs,9, " majority of programmers (you know who you are!),");
  310.   x_printf(textwindow_x+5,50+80,VisiblePageOffs,9, " willingly share their code and ideas with others.");
  311.  
  312.   x_printf(textwindow_x+5,50+88,VisiblePageOffs,9, "   I can't afford, nor do I want, to copyright");
  313.   x_printf(textwindow_x+5,50+96,VisiblePageOffs,9, " this code - but if you use it, some credit would ");
  314.   x_printf(textwindow_x+5,50+104,VisiblePageOffs,9," be appreciated. ");
  315.  
  316.   wait_for_keypress();
  317.  
  318.   subsequent_page();
  319.   x_set_font(0);
  320.   x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6,"Supported 256 colour resolutions.");
  321.   x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3,"Supported 256 colour resolutions.");
  322.   x_set_font(2);
  323.   x_printf(textwindow_x+5,50   ,VisiblePageOffs,9, " 320x200   Standard for games       ~ 4 pages");
  324.   x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " 320x240   DDJ Mode X square pixels ~ 3.5 pages");
  325.   x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " 360x200   My favourite for games   ~ 3 pages  ");
  326.   x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " 360x240                            ~ 2.8 pages");
  327.   x_printf(textwindow_x+5,50+32,VisiblePageOffs,9, " 320x400                            ~ 2 pages  ");
  328.   x_printf(textwindow_x+5,50+40,VisiblePageOffs,9, " 320x480   All subsequent modes support");
  329.   x_printf(textwindow_x+5,50+48,VisiblePageOffs,9, " 360x400     less than two pages.");
  330.   x_printf(textwindow_x+5,50+56,VisiblePageOffs,9, " 360x480");
  331.   x_printf(textwindow_x+5,50+64,VisiblePageOffs,9, " 376x282,360x360,376x308,376x564,256x200,256x240");
  332.   x_printf(textwindow_x+5,50+72,VisiblePageOffs,9, " Phew! and they'll run on all VGA cards and ");
  333.   x_printf(textwindow_x+5,50+80,VisiblePageOffs,9, " monitors (some of the weird ones are best suited");
  334.   x_printf(textwindow_x+5,50+88,VisiblePageOffs,9, " to monitors with both vert & horiz adjustments)");
  335.   x_printf(textwindow_x+5,50+98,VisiblePageOffs,2, "  ");
  336.   x_printf(textwindow_x+5,50+106,VisiblePageOffs,2," Overkill? Maybe!! ");
  337.  
  338.  
  339.   wait_for_keypress();
  340.  
  341.   subsequent_page();
  342.   x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6,"      Text display functions.");
  343.   x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3,"      Text display functions.");
  344.   x_set_font(2);
  345.   x_printf(textwindow_x+5,50   ,VisiblePageOffs,9, "   Several text printing functions are provided.");
  346.   x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " They support the VGA ROM 8x14 and 8x8 fonts as");
  347.   x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " well as user-defined fonts (like this 6x8 font).");
  348.   x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " Furthermore, a function similar to printf is");
  349.   x_printf(textwindow_x+5,50+32,VisiblePageOffs,9, " included which provides formatted text output.");
  350.   x_printf(textwindow_x+5,50+40,VisiblePageOffs,9, " User defined fonts may be proportionally spaced");
  351.   x_printf(textwindow_x+5,50+58,VisiblePageOffs,9, " but have a maximum width of 8 pixels.");
  352.  
  353.  
  354.   wait_for_keypress();
  355.  
  356.   subsequent_page();
  357.   x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6,"    Advanced screen functions.");
  358.   x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3,"    Advanced screen functions.");
  359.   x_set_font(2);
  360.   x_printf(textwindow_x+5,50   ,VisiblePageOffs,9, "   The library supports virtual screens larger");
  361.   x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " than the physical screen, panning of such");
  362.   x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " screens, and a split screen option.");
  363.   x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, "   These functions can be used together or");
  364.   x_printf(textwindow_x+5,50+32,VisiblePageOffs,9, " in isolation, and in the lower resolutions");
  365.   x_printf(textwindow_x+5,50+40,VisiblePageOffs,9, " double buffering can also be accomplished.");
  366.  
  367.   x_rect_fill(0, 0, ScrnPhysicalPixelWidth,60,SplitScrnOffs,5);
  368.   x_line(0,0,ScrnPhysicalPixelWidth,0,2,SplitScrnOffs);
  369.   x_set_font(1);
  370.   x_printf(10,10,SplitScrnOffs,2, " This is a split screen, tops for scores.");
  371.   x_set_font(0);
  372.   for (i=ScrnPhysicalHeight;i>ScrnPhysicalHeight-60;i--){
  373.     x_adjust_splitscreen(i);
  374.   }
  375.   x_printf(10,25,SplitScrnOffs,2, " Even better for scrolling games etc.");
  376.  
  377.   x_cp_vid_rect(0,0,ScrnLogicalPixelWidth,ScrnLogicalHeight,0,0,
  378.         VisiblePageOffs,HiddenPageOffs,
  379.         ScrnLogicalPixelWidth,ScrnLogicalPixelWidth);
  380.  
  381.  
  382.   x_show_mouse();
  383.   wait_for_keypress();
  384.  
  385.   curr_x=curr_y=0;
  386.  
  387.  
  388.   init_object(60,90,4, 12, -1, 1, MK_FP(FP_SEG(bm2),FP_OFF(bm2)));
  389.   init_object(30,30,4, 12, 1, 1, MK_FP(FP_SEG(bm),FP_OFF(bm)));
  390.   init_object(80,120,4, 12, 2, 1, MK_FP(FP_SEG(bm),FP_OFF(bm)));
  391.   init_object(300,200,4, 12, 1, -2, MK_FP(FP_SEG(bm),FP_OFF(bm)));
  392.   init_object(360,30,4, 12, -1, -1, MK_FP(FP_SEG(bm),FP_OFF(bm)));
  393.   init_object(360,10,4, 12, -2, 2, MK_FP(FP_SEG(bm),FP_OFF(bm)));
  394.  
  395.   x_hide_mouse();
  396.  
  397.   while (!kbhit()&& !(MouseButtonStatus==LEFT_PRESSED)){
  398.     animate();
  399.     if (objects[0].X>=curr_x+ScrnPhysicalPixelWidth-32 &&
  400.     curr_x < MaxScrollX) curr_x++;
  401.     else if (objects[0].X < curr_x+16 && curr_x > 0) curr_x--;
  402.     if (objects[0].Y>=curr_y+ScrnPhysicalHeight-92 &&
  403.        curr_y < MaxScrollY) curr_y++;
  404.     else if (objects[0].Y < curr_y+16 && curr_y > 0) curr_y--;
  405.     x_page_flip(curr_x,curr_y);
  406.     while(StartAddressFlag);
  407.   }
  408.   while(MouseButtonStatus==LEFT_PRESSED);
  409.   while(kbhit()) getch();
  410.  
  411.   clear_objects();
  412.   x_page_flip(curr_x,curr_y);
  413.   while(StartAddressFlag);
  414.  
  415.  
  416.   x_set_start_addr(0,0);
  417.  
  418.  
  419.   for (j=0;j<4;j++){
  420.     x_hide_splitscreen();
  421.     delay(100);
  422.     x_show_splitscreen();
  423.     delay(100);
  424.   }
  425.  
  426.  
  427.   for (i=ScrnPhysicalHeight-60;i<=ScrnPhysicalHeight;i++){
  428.     x_adjust_splitscreen(i);
  429.   }
  430.  
  431.   x_hide_mouse();
  432.   subsequent_page();
  433.   x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6,"        Palette functions.");
  434.   x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3,"        Palette functions.");
  435.   x_set_font(2);
  436.   x_printf(textwindow_x+5,50   ,VisiblePageOffs,9, "   A number of palette manipulation functions");
  437.   x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " are provided. You have already seen some of");
  438.   x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " them in action. Another common operation is");
  439.   x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " palette fading.                     ");
  440.  
  441.   i=0;
  442.   ch=255;
  443.   while (x_cpcontrast_pal_struc(pal, pal2,ch-=2)){
  444.     x_put_pal_struc(pal2);
  445.     x_rot_pal_struc(pal,palscrolldir);
  446.     i++;
  447.   };
  448.   for (j=0;j<i;j++){
  449.     x_cpcontrast_pal_struc(pal, pal2,ch+=2);
  450.     x_put_pal_struc(pal2);
  451.     x_rot_pal_struc(pal,palscrolldir);
  452.   };
  453.   wait_for_keypress();
  454.  
  455.   subsequent_page();
  456.   x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6,"    NEW Version 3.0 Functions!");
  457.   x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3,"    NEW Version 3.0 Functions!");
  458.   x_set_font(2);
  459.   x_printf(textwindow_x+5,50   ,VisiblePageOffs,9, " NEW functions not demonstrated here include:");
  460.   x_printf(textwindow_x+5,50+10,VisiblePageOffs,9, "  - RLE data compression");
  461.   x_printf(textwindow_x+5,50+20,VisiblePageOffs,9, "  - FAST compiled masked bitmaps");
  462.   x_printf(textwindow_x+5,50+30,VisiblePageOffs,9, "  - Hardware detection");
  463.  
  464.   x_show_mouse();
  465.   wait_for_keypress();
  466.  
  467.   x_hide_mouse();
  468.   for (i = 0; i < 150; i++) {
  469.       x_circle(0, 0, i, 181 - i, VisiblePageOffs);
  470.       x_circle(360 - i, 0, i, i + 30, VisiblePageOffs);
  471.       x_circle(0, 200 - i, i, i + 30, VisiblePageOffs);
  472.       x_circle(360 - i, 200 - i, i, 181 - i, VisiblePageOffs);
  473.   }
  474.   for (i = 0; i < 100; i++)
  475.     x_filled_circle(80 + i, i, 201 - (i << 1), 30+i, VisiblePageOffs);
  476.   x_show_mouse();
  477.   wait_for_keypress();
  478.  
  479.   subsequent_page();
  480.   x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6,"    NEW Version 4.0 Functions!");
  481.   x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3,"    NEW Version 4.0 Functions!");
  482.   x_set_font(2);
  483.   x_printf(textwindow_x+5,50   ,VisiblePageOffs,9, " NEW functions not demonstrated here include:");
  484.   x_printf(textwindow_x+5,50+10,VisiblePageOffs,9, "  - FAST VRAM-based masked bitmaps, including");
  485.   x_printf(textwindow_x+5,50+18,VisiblePageOffs,9, "      support for clipping regions");
  486.   x_printf(textwindow_x+5,50+28,VisiblePageOffs,9, "  - Faster, smaller compiled bitmaps");
  487.   x_printf(textwindow_x+5,50+38,VisiblePageOffs,9, "  - Improved planar bitmap performance and");
  488.   x_printf(textwindow_x+5,50+46,VisiblePageOffs,9, "      additional support for clipping");
  489.   x_printf(textwindow_x+5,50+56,VisiblePageOffs,9, "  - mouse module");
  490.   x_printf(textwindow_x+5,50+66,VisiblePageOffs,9, "  - Detection of math co-processor and mouse");
  491.   x_printf(textwindow_x+5,50+76,VisiblePageOffs,9, "  - Bezier curve module");
  492.   x_printf(textwindow_x+5,50+86,VisiblePageOffs,9, "  - Four new resolutions, including one with");
  493.   x_printf(textwindow_x+5,50+94,VisiblePageOffs,9, "      square pixels (376x282)");
  494.   x_printf(textwindow_x+5,50+104,VisiblePageOffs,9, "  - More bug fixes");
  495.  
  496.   wait_for_keypress();
  497.  
  498.   subsequent_page();
  499.   x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6,"    NEW Version 5.0 Functions!");
  500.   x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3,"    NEW Version 5.0 Functions!");
  501.   x_set_font(2);
  502.   x_printf(textwindow_x+5,50   ,VisiblePageOffs,9, " - *FAST* filled and clipped triangles ideal for");
  503.   x_printf(textwindow_x+5,50+10,VisiblePageOffs,9, "   3D work. Thanks to S. Dollins for the code.");
  504.   x_printf(textwindow_x+5,50+20,VisiblePageOffs,9, " - Filled and clipped polygons, C++ Compatible");
  505.   x_printf(textwindow_x+5,50+30,VisiblePageOffs,9, " - header files, and of course bug fixes!");
  506.  
  507.   x_show_mouse();
  508.   wait_for_keypress();
  509.  
  510.   subsequent_page();
  511.   x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6,"    NEW Version 6.0 Functions!");
  512.   x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3,"    NEW Version 6.0 Functions!");
  513.   x_set_font(2);
  514.   x_printf(textwindow_x+5,50   ,VisiblePageOffs,9, " - Fast flood filling functions ");
  515.   x_printf(textwindow_x+5,50+10,VisiblePageOffs,9, " - New pbm flipping put functions.");
  516.   x_printf(textwindow_x+5,50+20,VisiblePageOffs,9, " - Timer synchronized vertical retrace");
  517.   x_printf(textwindow_x+5,50+30,VisiblePageOffs,9, " - Tripple buffering extensions");
  518.   x_printf(textwindow_x+5,50+40,VisiblePageOffs,9, " Checkout demo 9 and 10 for previews");
  519.   
  520.  
  521.  
  522.   x_show_mouse();
  523.   wait_for_keypress();
  524.  
  525.  
  526.   randomize();
  527.   x_hide_mouse();
  528.   while(kbhit()) getch();
  529.   palscrolldir^=1;
  530.   do {
  531.     int x0,x1,x2,y0,y1,y2,i;
  532.     i=random(256);
  533.     x0=random(ScrnLogicalPixelWidth);
  534.     x1=random(ScrnLogicalPixelWidth);
  535.     x2=random(ScrnLogicalPixelWidth);
  536.     y0=random(ScrnPhysicalHeight);
  537.     y1=random(ScrnPhysicalHeight);
  538.     y2=random(ScrnPhysicalHeight);
  539.     x_triangle(x0,y0,x1,y1,x2,y2,i,VisiblePageOffs);
  540.   } while (!kbhit() && !(MouseButtonStatus==LEFT_PRESSED));
  541.   while(MouseButtonStatus==LEFT_PRESSED);
  542.   while(kbhit()) getch();
  543.   x_show_mouse();
  544.  
  545.   subsequent_page();
  546.   x_printf(textwindow_x+24,textwindow_y+18,VisiblePageOffs,6,"             PLEASE...");
  547.   x_printf(textwindow_x+23,textwindow_y+17,VisiblePageOffs,3,"             PLEASE...");
  548.   x_set_font(2);
  549.   x_printf(textwindow_x+5,50   ,VisiblePageOffs,9, "   Please mention my name in programs that use XLIB");
  550.   x_printf(textwindow_x+5,50+8 ,VisiblePageOffs,9, " just to make me feel it was worth the effort.");
  551.   x_printf(textwindow_x+5,50+16,VisiblePageOffs,9, " If you have any bug to report please feel free to");
  552.   x_printf(textwindow_x+5,50+24,VisiblePageOffs,9, " mail me a message. Any hints, suggestions and");
  553.   x_printf(textwindow_x+5,50+32,VisiblePageOffs,9, " contributions are welcome and encouraged.");
  554.   x_printf(textwindow_x+5,50+52,VisiblePageOffs,9, " I have contributed this code to the public domain.");
  555.   x_printf(textwindow_x+5,50+60,VisiblePageOffs,9, "    Please respect my wishes and leave it there.");
  556.  
  557.   x_printf(textwindow_x+5,50+80,VisiblePageOffs,9, "   Finally, I hope you all find this stuff useful,");
  558.   x_printf(textwindow_x+5,50+96,VisiblePageOffs,9, " Themie Gouthas - EGG@DSTOS3.DSTO.GOV.AU");
  559.  
  560.   wait_for_keypress();
  561.  
  562.   x_hide_mouse();
  563.  
  564.   x_shift_rect (27, 27, 360-27, 177, 27, 23, VisiblePageOffs);
  565.   x_rect_fill(25, 173, 335, 176, VisiblePageOffs, 1);
  566.   for (i = 0; i < 50; i++) {
  567.     x_shift_rect (27, 26, 360-27, 177 - (i * 3), 27, 23, VisiblePageOffs);
  568.   }
  569. }
  570.  
  571.  
  572.